import sys

def main(arg):
	if(len(arg) != 1) : return
	py = {}
	buf = file(arg[0]).read()
	buf = unicode(buf, "utf16")
	buf = buf.strip().split('\n')
	npy = 0
	word = []
	cc = 0
	for line in buf:
		line = line.split()
		cpy = []
		for i in line[3:]:
			if i == 'ng' : i = 'en'
			if i not in py:
				py[i] = npy
				npy += 1
			cpy += [py[i]]
		word += [(cpy,float(line[1]),int(line[2]),line[0])]
		cc += 1
	print len(py)
	for i in py:
		print "%d %s"%(py[i],i)
	print cc
	for i in word:
		buf = "%d "%len(i[0])
		for j in i[0]:
			buf += "%d "%j
		buf += "%s "%i[1]
		buf += i[3].encode('utf8')
		print buf

main(sys.argv[1:])
